def p(n):
    for i in range(2,n):
        if n % i == 0:
            return False
    return True



x = []
j = ['zero','one','two','three','four','five','six','seven','eight','nine']
a = input().split()
if len(a)<3 or a[0] not in j or a[1] not in j or a[2] not in j:
    print("Wrong input")
else:
    for i in a:
        if i == 'one':
            x.append('1')
        if i == 'two':
            x.append('2')
        if i == 'three':
            x.append('3')
        if i == 'four':
            x.append('4')
        if i == 'five':
            x.append('5')
        if i == 'six':
            x.append('6')
        if i == 'seven':
            x.append('7')
        if i == 'eight':
            x.append('8')
        if i == 'nine':
            x.append('9')
    s = ''.join(x)
    prost = []
    for i in range(2, 1500):
        if p(i):
            prost.append(i)
    mn = 10000
    k = 0
    for i in prost:
        if abs(i-int(s)) < mn:
            mn = abs(i-int(s))
            k = i
    print(k)
